<?php
class My_Helper_DisplayTree {
	public $array;
	public function __construct() {
		$this->arr = new My_Helper_Array ( );
	}
	
	public function makeTree($id) {
		$tree = $this->arr->array_to_tree ( $this->array, "id" );
		return $this->dis ( $tree, $id );
	}
	
	public function dis($tree,$id = null) {
		foreach ( $tree as $key => $value ) {
			if ($value ["childrens"] != "") {
				$qq = $qq . "<li>" . $value ["name"] . "\n";
				$qq = $qq . $this->dis ( $value ["childrens"] ) . "</li>" . "\n";
			} else {
				$qq = $qq . "<li>" . $value ['name'] . "</li>" . "\n";
			}
		}
		return "<ul id=$id>" . $qq . "</ul>";
	}
	public function getChilds($parent_id) {
		$tree = $this->arr->array_to_tree ( $this->array, "id", 'parent_id', 'childrens', true );
		return $this->arr->tree_to_array ( $tree ["refs"] [$parent_id] );
	}

}

?>